Telegram Group & Telegram Channel
Вопрос с собеседования

Зачем в Java нужны volatile переменные, если есть synchronized?

Ответ: volatile обеспечивает немедленную видимость изменений переменной между потоками, но не гарантирует атомарность операций. Он легче и быстрее, чем synchronized, но подходит только для простых сценариев чтения и записи. Для сложных операций, где важна целостность состояния, требуется synchronized или другие механизмы синхронизации.

tags: #собеседование

📱 Java Developer | Чат
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/java_tg/2916
Create:
Last Update:

Вопрос с собеседования

Зачем в Java нужны volatile переменные, если есть synchronized?

Ответ: volatile обеспечивает немедленную видимость изменений переменной между потоками, но не гарантирует атомарность операций. Он легче и быстрее, чем synchronized, но подходит только для простых сценариев чтения и записи. Для сложных операций, где важна целостность состояния, требуется synchronized или другие механизмы синхронизации.

tags: #собеседование

📱 Java Developer | Чат

BY Java Developer


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_tg/2916

View MORE
Open in Telegram


Java Developer Telegram | DID YOU KNOW?

Date: |

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

Java Developer from us


Telegram Java Developer
FROM USA